package com.example.service.Impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.dao.BookDao;
import com.example.domain.Book;
import com.example.service.BookService;
import com.example.service.MsgService;
import org.apache.logging.log4j.util.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class MsgServiceImpl implements MsgService {


    // 采用哈希集合存储缓存数据 方便重复使用 降低数据库链接次数 提升效率
    private HashMap<String,String> caches = new HashMap<>();


    @Override
    public String get(String tele) {
        String code = tele.substring(tele.length()-6);
        caches.put(tele,code);
        return code;
    }

    @Override
    public Boolean check(String tele, String code) {
       Boolean queryCode= caches.get(tele).equals(code);
        return queryCode;
    }
}
